/******************************************************************************
 * Copyright 2023 The Apollo Authors. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *****************************************************************************/

#include "modules/canbus_vehicle/x3epro/protocol/aeb_systemstate_11.h"
#include "glog/logging.h"
#include "modules/drivers/canbus/common/byte.h"
#include "modules/drivers/canbus/common/canbus_consts.h"

namespace apollo {
namespace canbus {
namespace x3epro {

using ::apollo::drivers::canbus::Byte;

Aebsystemstate11::Aebsystemstate11() {}
const int32_t Aebsystemstate11::ID = 0x11;

void Aebsystemstate11::Parse(const std::uint8_t* bytes, int32_t length,
                         X3epro* chassis) const {
  chassis->mutable_aeb_systemstate_11()->set_aeb_state(aeb_state(bytes, length));
  chassis->mutable_aeb_systemstate_11()->set_aeb_brakestate(aeb_brakestate(bytes, length));
}

// config detail: {'bit': 1, 'enum': {0: 'AEB_STATE_ULTRASONIC_ONLY', 1: 'AEB_STATE_ULTRASONIC_BRAKE_NORMAL'}, 'is_signed_var': False, 'len': 2, 'name': 'aeb_state', 'offset': 0.0, 'order': 'motorola', 'physical_range': '[0|0]', 'physical_unit': '', 'precision': 1.0, 'type': 'enum'}
Aeb_systemstate_11::Aeb_stateType Aebsystemstate11::aeb_state(const std::uint8_t* bytes, int32_t length) const {
  Byte t0(bytes + 0);
  int32_t x = t0.get_byte(0, 2);

  Aeb_systemstate_11::Aeb_stateType ret =  static_cast<Aeb_systemstate_11::Aeb_stateType>(x);
  return ret;
}

// config detail: {'bit': 2, 'enum': {0: 'AEB_BRAKESTATE_BRAKE_OFF', 1: 'AEB_BRAKESTATE_BRAKE_ON'}, 'is_signed_var': False, 'len': 1, 'name': 'aeb_brakestate', 'offset': 0.0, 'order': 'motorola', 'physical_range': '[0|0]', 'physical_unit': '', 'precision': 1.0, 'type': 'enum'}
Aeb_systemstate_11::Aeb_brakestateType Aebsystemstate11::aeb_brakestate(const std::uint8_t* bytes, int32_t length) const {
  Byte t0(bytes + 0);
  int32_t x = t0.get_byte(2, 1);

  Aeb_systemstate_11::Aeb_brakestateType ret =  static_cast<Aeb_systemstate_11::Aeb_brakestateType>(x);
  return ret;
}
}  // namespace x3epro
}  // namespace canbus
}  // namespace apollo
